import request from '@/utils/request'

// 定义首页仪表板数据类型
export interface DashboardData {
  statistics: {
    userGrowth: {
      total: number
      dailyGrowth: Array<{
        date: string
        count: number
      }>
      monthlyGrowth: Array<{
        month: string
        count: number
      }>
    }
    contentPublish: {
      total: {
        publishes: number
        shortVideos: number
      }
      dailyPublishes: Array<{
        date: string
        count: number
      }>
      dailyShortVideos: Array<{
        date: string
        count: number
      }>
    }
    interactions: {
      total: {
        likes: number
        comments: number
      }
      dailyLikes: Array<{
        date: string
        count: number
      }>
      dailyComments: Array<{
        date: string
        count: number
      }>
    }
    userActivity: {
      totalActiveUsers: number
      dailyActiveUsers: Array<{
        date: string
        count: number
      }>
    }
    contentCategory: {
      publishes: {
        public: number
        private: number
      }
      shortVideos: {
        public: number
        private: number
      }
      publishImages: {
        withImages: number
        withoutImages: number
      }
    }
    userHeatmap: Array<{
      dayOfWeek: number
      hourOfDay: number
      count: number
    }>
  }
  leaderboards: {
    topUsers: Array<{
      user_id: number
      name: string
      avatar: string
      publishCount: number
    }>
    topPublishes: Array<{
      publish_id: number
      content: string
      like_count: number
      author: string | null
    }>
    topShortVideos: Array<{
      video_id: number
      title: string
      like_count: number
      author: string | null
    }>
  }
  recentActivities: {
    recentUsers: Array<{
      user_id: number
      name: string
      avatar: string
      createdAt: string
    }>
    recentPublishes: Array<{
      publish_id: number
      content: string
      createdAt: string
      author: string | null
    }>
    recentShortVideos: Array<{
      video_id: number
      title: string
      createdAt: string
      author: string | null
    }>
  }
}

// 获取首页仪表板数据
export const getDashboardData = (days?: number) => {
  return request({
    url: '/home/dashboard',
    method: 'GET',
    params: { days }
  })
}